package com.oocl.crm.util;

public class FormatCmd {
	public static String cmdKind(String cmd){
		String resultString = cmd.substring(0, 1).toUpperCase();
		return resultString;
	}
	
	public static String[] cmdCondition(String cmd){
		if(FormatCmd.cmdKind(cmd).equals("U")){
			String[] temp = cmd.split(" ");
			String[] conditionsTemp = temp[2].split(",");
			String[] conditions = new String[conditionsTemp.length+1];
			conditions[0] = temp[1];
			for(int i=1; i<conditions.length; i++){
				conditions[i] = conditionsTemp[i-1];
			}
			return conditions;
		}else if(cmd.length() >2){
			cmd = cmd.substring(2);
			String[] conditions = cmd.split(",");
			return conditions;
		}else{
			return null;
		}
	}
	
	public static String[] cmdKeyValue(String string){
		if(string != null){
			String[] kv = string.split(":");
			return kv;
		}
		return null;
	}

}
